package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import java.util.Map;

@Mapper
public interface UserMapper {
    /**
     * 用户登录查询
     * @param user
     * @return
     */
    @Select("select * from sky_take_out.user where openid=#{openid}")
    User login(User user);

    /**
     * 用户注册
     * @param user
     */
    @Insert("insert into sky_take_out.user values (null,#{openid},#{name},#{phone},#{sex},#{idNumber},#{avatar},#{createTime})")
    void add(User user);

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Select("select * from sky_take_out.user where id=#{id}")
    User getById(Long id);

    /**
     * 统计新增用户
     * @param map
     * @return
     */
    Integer userStatistics(Map<String, Object> map);
}
